﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameManager : MonoBehaviour
{
    public GameObject player_bullet_source;
    public GameObject android_bullet_source;

    public GameObject android_source;

    public Transform player_shoter;

    public int easyAndroidCount = 4;
    public int normalAndroidCount = 4;
    public int hardAndroidCount = 4;

    // Start is called before the first frame update
    void Start()
    {
        init();
    }
    private void Awake()
    {
        GameInfo.Instance.Restart();
        //GameInfo.Instance.AndroidBulletPool.Clear();
        //GameInfo.Instance.AndroidPool.Clear();
        //GameInfo.Instance.PlayerBulletPool.Clear();
        Time.timeScale = 1;
        
    }
    // Update is called once per frame
    void Update()
    {
        
    }
    private void init()
    {
        initBulletPool();
    }

    void initBulletPool()
    {
        for(int i=0;i<100;i++)
        {
            GameObject bull = Instantiate(player_bullet_source);
            GameInfo.Instance.PlayerBulletPool.Enqueue(bull.transform);
            bull.SetActive(false);
        }
        for(int i=0;i<100;i++)
        {
            GameObject bull = Instantiate(android_bullet_source);            
            GameInfo.Instance.AndroidBulletPool.Enqueue(bull.transform);
            bull.SetActive(false);
        }

        for(int i=0;i< easyAndroidCount; i++)
        {
            GameObject android = Instantiate(android_source);
            android.GetComponent<Andorid_Controller>().android_Kind = Android_Kind.EASY;
            GameInfo.Instance.AndroidPool.Add(android.transform);
            android.SetActive(false);
        }
        for (int i = 0; i < normalAndroidCount; i++)
        {
            GameObject android = Instantiate(android_source);
            android.GetComponent<Andorid_Controller>().android_Kind = Android_Kind.NORMAL;
            GameInfo.Instance.AndroidPool.Add(android.transform);
            android.SetActive(false);
        }
        for (int i = 0; i < hardAndroidCount; i++)
        {
            GameObject android = Instantiate(android_source);
            android.GetComponent<Andorid_Controller>().android_Kind = Android_Kind.HARD;
            GameInfo.Instance.AndroidPool.Add(android.transform);
            android.SetActive(false);
        }
        GameInfo.Instance.onEnemyChange(easyAndroidCount + normalAndroidCount + hardAndroidCount);
        GameInfo.Instance.SetAndroidCount(easyAndroidCount + normalAndroidCount + hardAndroidCount);
    }
}
